package com.ming.sevice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ming.domain.PickAddr;
import com.ming.mapper.PickAddrMapper;
import com.ming.sevice.PickAddrService;
import org.springframework.util.StringUtils;

/**
 * @Author:何元才
 * @Desc:
 * @data:2021-04-02 15:48
 */
@Service
public class PickAddrServiceImpl extends ServiceImpl<PickAddrMapper, PickAddr> implements PickAddrService {


    @Autowired
    private PickAddrMapper pickAddrMapper;

    /**
     * 自提点分页
     *
     * @param page
     * @param pickAddr
     * @return
     */
    @Override
    public Page<PickAddr> findPickAddrPage(Page<PickAddr> page, PickAddr pickAddr) {
        Page<PickAddr> pickAddrPage = pickAddrMapper.selectPage(page, new LambdaQueryWrapper<PickAddr>()
                .like(StringUtils.hasText(pickAddr.getAddrName()), PickAddr::getAddrName, pickAddr.getAddrName())
                .orderByDesc(PickAddr::getAddrId)
        );
        return pickAddrPage;
    }
}
